package com.wyx.regexp;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author 王艺锡
 * @version 1.0
 */
public class regExp11 {
    public static void main(String[] args) {
        String content = "我我...要要要要...学学编程";

       //1.首先去掉所有的.
        Pattern pattern = Pattern.compile("\\.");
        Matcher matcher = pattern.matcher(content);
        content = matcher.replaceAll("");
        System.out.println(content);


        /*//2.去掉所有重复的字
        //(1)先捕获重复的字(.)\\1+
        //(2)使用外部反向引用替换重复的字
        pattern = Pattern.compile("(.)\\1+");
        matcher = pattern.matcher(content);
        content = matcher.replaceAll("$1");
        System.out.println(content);*/



        //综合为一句话
        content = Pattern.compile("(.)\\1+").matcher(content).replaceAll("$1");
        System.out.println(content);

    }
}
